package Slides
{
	import SplineComponent.SplineComponentView;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filesystem.File;
	import flash.net.FileFilter;
	
	import mvc.Controller;
	
	import mx.collections.XMLListCollection;
	import mx.containers.Canvas;
	import mx.containers.Panel;
	import mx.controls.Alert;
	import mx.controls.Button;
	import mx.controls.ColorPicker;
	import mx.controls.ComboBox;
	import mx.controls.Label;
	import mx.controls.LinkButton;
	import mx.controls.MenuBar;
	import mx.controls.TextInput;
	import mx.events.MenuEvent;
	
	import util.Observable;
	
	public class SlideView extends SplineComponentView
	{
		private var stage:Object;
		
		private var mainPanel : Panel;
		private var makeSlideCnvs :Canvas;
		private var thumbSlideCnvs : Canvas;
		
		private var mainMenuBar : MenuBar;
		private var mainMenuXmlList : XMLList;
		private var mainMenuXmlListCol : XMLListCollection;
		
		private var displayCnvs : Canvas;
		private var textbtnsCnvs : Canvas;
		private var imagebtnsCnvs : Canvas;
		private var templatebtnsCnvs : Canvas;
		private var animationbtnsCnvs : Canvas;
		private var slideshowCnvs : Canvas;
		
		private var addSlideBtn : Button;
		private var removeSlideBtn : Button;
		private var nextSlideBtn : Button;
		private var previousSlideBtn : Button;
		
		private var addTxtBtn : LinkButton;
		private var boldBtn : LinkButton;
		private var italicBtn : LinkButton;
		private var underlineBtn : LinkButton;
		private var colorPick : ColorPicker;
		private var fontfamilySel : ComboBox;
		private var fontsizeSel : ComboBox;
		
		private var addImgBtn : LinkButton;
		private var removeImgBtn : LinkButton;
		private var rotateInput : TextInput;
		private var heightInput : TextInput;
		private var widthInput : TextInput;
		
		private var layoutCnvs1 : Canvas;
		private var layoutCnvs2 : Canvas;
		private var layoutCnvs3 : Canvas;
		
		private var transitionSel : ComboBox ;
		private var directionSel : ComboBox ; 
		private var speedSel : ComboBox;
		private var previewBtn : LinkButton;
		
		private var playFrmBeginBtn : Button;
		private var playFrmcrntslideBtn : Button;
		
		private var No_of_Slides : int;
		
		private var thumbArray : Array;
		private var makeArray : Array;
		private var loadArray : Array;
		private var thumbY : int;
		private var selIndex : int ;
		private var model : SlideModel;
		private var selChildIndex : Object;
		private var lessonEditMode_bool:Boolean;
		private var controller:Object;
		public function SlideView(model:Observable,controller:Controller,lessonView:Object,lessonEditMode:Boolean)
		{
			super(model,controller);
			this.controller=this.getController();
			this.stage=lessonView;
			this.lessonEditMode_bool = lessonEditMode;
			createView();
			super.makePanelDraggable(this.mainPanel);
			super.makePanelResizable();
		}
		
		private function createView():void{
			
			this.mainPanel=new Panel;
			mainPanel.percentHeight=100;
			mainPanel.percentWidth=100;
			mainPanel.title="My Slide Presentation";
			mainPanel.layout="absolute";
			this.stage.addChildToStage(this.mainPanel);
			
			this.makeSlideCnvs=new Canvas;
			makeSlideCnvs.setStyle("backgroundColor",0xF8BCBC);
			makeSlideCnvs.setStyle("borderStyle","solid");
			makeSlideCnvs.x=200;
			makeSlideCnvs.y=120;
			makeSlideCnvs.percentHeight=60;
			makeSlideCnvs.percentWidth=60;
			this.mainPanel.addChild(this.makeSlideCnvs);
			
			this.thumbSlideCnvs=new Canvas;
			thumbSlideCnvs.setStyle("backgroundColor",0xCFD8FE);
			thumbSlideCnvs.x=10;
			thumbSlideCnvs.y=120;
			thumbSlideCnvs.percentHeight=60;
			thumbSlideCnvs.width=120;
			this.mainPanel.addChild(this.thumbSlideCnvs);
			
			this.mainMenuXmlList=
								<>
				                    <menuitem label="File" data="1">
				                    	<submenuItem label="New" data="1A" />
				                    	<submenuItem label="Open" data="1B" />
				                    	<submenuItem label="Save" data="1C" />
				                    </menuitem>
				                    <menuitem label="Insert Text" data="2" />
				                    <menuitem label="Insert Image" data="3" />
				                    <menuitem label="Templates" data="4" />
				                     <menuitem label="Animation" data="5" />
				                    <menuitem label="Slide Show" data="6" />
				                </>;
				                
			this.mainMenuXmlListCol=new XMLListCollection(this.mainMenuXmlList);
			
			this.mainMenuBar=new MenuBar;
			mainMenuBar.dataProvider=this.mainMenuXmlListCol;
			mainMenuBar.labelField="@label";
			
			mainMenuBar.percentWidth=100;
			mainMenuBar.height=20;
			this.mainPanel.addChild(this.mainMenuBar);	
			mainMenuBar.addEventListener(MenuEvent.CHANGE,menuHandler);
			
			this.displayCnvs=new Canvas;
			displayCnvs.percentWidth=100;
			displayCnvs.height=45;
			displayCnvs.y=20;
			displayCnvs.setStyle("borderStyle","outset");
			displayCnvs.setStyle("backgroundColor",0xdddada);
			this.mainPanel.addChild(this.displayCnvs);
			
			this.textbtnsCnvs=new Canvas;
			textbtnsCnvs.percentWidth=100;
			textbtnsCnvs.height=40;
			textbtnsCnvs.setStyle("borderStyle","outset");
			textbtnsCnvs.setStyle("backgroundColor",0xdddada);
			
			this.imagebtnsCnvs=new Canvas;
			imagebtnsCnvs.percentWidth=100;
			imagebtnsCnvs.height=40;
			imagebtnsCnvs.setStyle("borderStyle","outset");
			imagebtnsCnvs.setStyle("backgroundColor",0xdddada);
			
			this.templatebtnsCnvs=new Canvas;
			templatebtnsCnvs.percentWidth=100;
			templatebtnsCnvs.height=40;
			templatebtnsCnvs.setStyle("borderStyle","outset");
			templatebtnsCnvs.setStyle("backgroundColor",0xdddada);
			
			this.animationbtnsCnvs=new Canvas;
			animationbtnsCnvs.percentWidth=100;
			animationbtnsCnvs.height=40;
			animationbtnsCnvs.setStyle("borderStyle","outset");
			animationbtnsCnvs.setStyle("backgroundColor",0xdddada);
			
			this.slideshowCnvs=new Canvas;
			slideshowCnvs.percentWidth=100;
			slideshowCnvs.height=40;
			slideshowCnvs.setStyle("borderStyle","outset");
			slideshowCnvs.setStyle("backgroundColor",0xdddada);
			
			this.addSlideBtn=new Button;
			addSlideBtn.x=10;
			addSlideBtn.y=400;
			addSlideBtn.label="+";
			addSlideBtn.addEventListener(MouseEvent.CLICK,addSlide);
			this.mainPanel.addChild(addSlideBtn);
			
			this.removeSlideBtn=new Button;
			removeSlideBtn.x=60;
			removeSlideBtn.y=400;
			removeSlideBtn.label="-";
			removeSlideBtn.enabled=false;
			removeSlideBtn.addEventListener(MouseEvent.CLICK,removeSlide);
			this.mainPanel.addChild(removeSlideBtn);
			
			this.No_of_Slides=new int;
			this.No_of_Slides=1;
			
			this.thumbArray=new Array;
			this.makeArray=new Array;
			this.loadArray=new Array;
			this.thumbY=new int;
			this.selIndex=new int;
			this.selChildIndex=new Object;
			
			this.thumbY=0;
			this.selIndex=0;
			this.selChildIndex.int=1;
			
			var thumbCnvs : Canvas=new Canvas;
			thumbCnvs.width=this.thumbSlideCnvs.width-20;
			thumbCnvs.setStyle("backgroundColor",0xFFFFFF);
			thumbCnvs.height=80;
			thumbCnvs.x=10;
			thumbCnvs.y=thumbY+10;
			this.thumbArray.push(thumbCnvs);
			this.thumbSlideCnvs.addChild(thumbCnvs);
			thumbCnvs.addEventListener(MouseEvent.CLICK,changeSelIndex);
			thumbY=thumbCnvs.y+thumbCnvs.height;
			
			/*var MakeCnvs : Canvas=new Canvas;
			MakeCnvs.setStyle("backgroundColor",0xFFFFFF);
			MakeCnvs.x=0;
			MakeCnvs.y=0;
			MakeCnvs.percentHeight=100;
			MakeCnvs.percentWidth=100;
			this.makeSlideCnvs.addChild(MakeCnvs);
			this.makeArray.splice(this.selIndex,0,MakeCnvs);*/
			
			
	//=======================Buttons for text canvas===============================		
			this.addTxtBtn=new LinkButton;
			addTxtBtn.label="Add";
			addTxtBtn.x=10;
			this.textbtnsCnvs.addChild(this.addTxtBtn);
			
			this.boldBtn=new LinkButton;
			boldBtn.label="B";
			boldBtn.x=50;
			this.textbtnsCnvs.addChild(this.boldBtn);
			
			this.italicBtn=new LinkButton;
			italicBtn.label="I";
			italicBtn.x=90;
			this.textbtnsCnvs.addChild(this.italicBtn);
			
			this.underlineBtn=new LinkButton;
			underlineBtn.label="U";
			underlineBtn.x=130;
			this.textbtnsCnvs.addChild(this.underlineBtn);
			
			this.colorPick=new ColorPicker;
			colorPick.x=170;
			this.textbtnsCnvs.addChild(this.colorPick);
			
			this.fontfamilySel=new ComboBox;
			fontfamilySel.x=210;
			this.textbtnsCnvs.addChild(this.fontfamilySel);
			
			this.fontsizeSel=new ComboBox;
			fontsizeSel.x=410;
			fontsizeSel.width=40;
			this.textbtnsCnvs.addChild(this.fontsizeSel);
			
			
	
	//========================XXXXXXXXXXXXXXXXXXXXXXXXX========================
	
	//=======================Buttons for Image canvas===============================	
			this.addImgBtn=new LinkButton;
			addImgBtn.label="Add";
			addImgBtn.x=10;
			this.imagebtnsCnvs.addChild(addImgBtn);
			addImgBtn.addEventListener(MouseEvent.CLICK,addImage);
			
			
			
			this.removeImgBtn=new LinkButton;
			removeImgBtn.label="Rem";
			removeImgBtn.x=320;
			this.imagebtnsCnvs.addChild(removeImgBtn);
			removeImgBtn.addEventListener(MouseEvent.CLICK,removeImage);
			
			var rotLbl :Label=new Label;
			rotLbl.text="Rotate";
			rotLbl.x=80;
			this.imagebtnsCnvs.addChild(rotLbl);
			
			this.rotateInput=new TextInput;
			rotateInput.x=120;
			rotateInput.width=30;
			this.imagebtnsCnvs.addChild(rotateInput);
			
			var HtLbl :Label=new Label;
			HtLbl.text="Height";
			HtLbl.x=150;
			this.imagebtnsCnvs.addChild(HtLbl);
			
			this.heightInput=new TextInput;
			heightInput.x=190;
			heightInput.width=30;
			this.imagebtnsCnvs.addChild(heightInput);
			
			var  WdLbl :Label=new Label;
			WdLbl.text="Width";
			WdLbl.x=230;
			this.imagebtnsCnvs.addChild(WdLbl);
			
			this.widthInput=new TextInput;
			widthInput.x=270;
			widthInput.width=30;
			this.imagebtnsCnvs.addChild(widthInput);

			
	//========================XXXXXXXXXXXXXXXXXXXXXXXXX========================	
	
	//=======================Buttons for Template canvas===========================
			
			this.layoutCnvs1=new Canvas;
			layoutCnvs1.x=10;
			layoutCnvs1.setStyle("backgroundColor",0x387429);
			layoutCnvs1.width=40;
			layoutCnvs1.height=30;
			this.templatebtnsCnvs.addChild(layoutCnvs1);
			
			this.layoutCnvs2=new Canvas;
			layoutCnvs2.x=70;
			layoutCnvs2.setStyle("backgroundColor",0x387429);
			layoutCnvs2.width=40;
			layoutCnvs2.height=30;
			this.templatebtnsCnvs.addChild(layoutCnvs2);
			
			this.layoutCnvs3=new Canvas;
			layoutCnvs3.x=130;
			layoutCnvs3.setStyle("backgroundColor",0x387429);
			layoutCnvs3.width=40;
			layoutCnvs3.height=30;
			this.templatebtnsCnvs.addChild(layoutCnvs3);
			
			
	//========================XXXXXXXXXXXXXXXXXXXXXXXX==========================
	
	//=======================Buttons for Animation canvas========================
		
			var effectsLbl : Label=new Label;
			effectsLbl.text="Effects";
			effectsLbl.x=10;
			this.animationbtnsCnvs.addChild(effectsLbl);
			
			this.transitionSel=new ComboBox;
			transitionSel.x=60;
			transitionSel.width=60;
			this.animationbtnsCnvs.addChild(transitionSel);
			
			var dirLbl : Label=new Label;
			dirLbl.text="Direction";
			dirLbl.x=140;
			this.animationbtnsCnvs.addChild(dirLbl);
			
			this.directionSel=new ComboBox;
			directionSel.x=220;
			directionSel.width=60;
			this.animationbtnsCnvs.addChild(directionSel);
			
			var speedLbl : Label=new Label;
			speedLbl.text="Speed";
			speedLbl.x=300;
			this.animationbtnsCnvs.addChild(speedLbl);
			
			this.speedSel=new ComboBox;
			speedSel.x=380;
			speedSel.width=60;
			this.animationbtnsCnvs.addChild(speedSel);
			
			
	//========================XXXXXXXXXXXXXXXXXXXXXXXX==========================	
	
	//=======================Buttons for SlideShow canvas========================
	
			this.playFrmBeginBtn=new Button;
			playFrmBeginBtn.label="Play From First Slide";	
			playFrmBeginBtn.x=10;
			this.slideshowCnvs.addChild(playFrmBeginBtn);
			
			this.playFrmcrntslideBtn=new Button;
			playFrmcrntslideBtn.label="Play From Current Slide";	
			playFrmcrntslideBtn.x=210;
			this.slideshowCnvs.addChild(playFrmcrntslideBtn);
			
			
	//========================XXXXXXXXXXXXXXXXXXXXXXXX==========================		              
		}
		
		
		public function fromModeltoView(infoObject:Object):void{
			
			switch(infoObject.message.toString()){
				
				case "Open complete" :
					trace("I m in open complete"+infoObject.NoOfSlides);
					loadSlide(infoObject);
					break;
			}
		}
		
		private function menuHandler(event:MenuEvent):void{
			switch(event.item.@label.toString())
			{
				
				case "Save" :{
					SaveSlide();
				}
				case "Insert Text" :{
					this.displayCnvs.removeAllChildren();
					this.displayCnvs.addChild(this.textbtnsCnvs);
					break ;
					
				}
				
				case "Insert Image" :{
					this.displayCnvs.removeAllChildren();
					this.displayCnvs.addChild(this.imagebtnsCnvs);
					break ;
				}
				
				case "Templates" :{
					this.displayCnvs.removeAllChildren();
					this.displayCnvs.addChild(this.templatebtnsCnvs);
					break ;
				}
				
				case "Animation" :{
					this.displayCnvs.removeAllChildren();
					this.displayCnvs.addChild(this.animationbtnsCnvs);
					break ;
				}
				
				case "Slide Show" :{
					this.displayCnvs.removeAllChildren();
					this.displayCnvs.addChild(this.slideshowCnvs);
					break ;
				}
				
				case "Open" : {
					openSlide();
				}
				
			}

		}
		
		private function addSlide(event:MouseEvent):void {
			
			var addslideReqObj : Object=new Object;
			addslideReqObj.message="Add slide";
			this.model.fromViewtoModel(addslideReqObj);
			this.removeSlideBtn.enabled=true;
			this.No_of_Slides++;
			this.selIndex++;

			var thumbCnvs : Canvas=new Canvas;
			thumbCnvs.setStyle("backgroundColor",0xFFFFFF);
			thumbCnvs.width=this.thumbSlideCnvs.width-20;
			this.thumbArray.splice(this.selIndex,0,thumbCnvs);
			thumbCnvs.addEventListener(MouseEvent.CLICK,changeSelIndex);
			updateThumbPanel();
			
			/*var MakeCnvs : Canvas=new Canvas;
			MakeCnvs.setStyle("backgroundColor",0xFFFFFF);
			MakeCnvs.x=0;
			MakeCnvs.y=0;
			MakeCnvs.percentHeight=100;
			MakeCnvs.percentWidth=100;
			this.makeArray.splice(this.selIndex,0,MakeCnvs);*/
			//updateMakePanel();
		}
		
		private function removeSlide(event:MouseEvent):void{
			var removeslideReqObj : Object=new Object;
			removeslideReqObj.message="Remove slide";
			this.model.fromViewtoModel(removeslideReqObj);
			
			this.thumbArray.splice(this.selIndex,1);
			//this.makeArray.splice(this.selIndex,1);
			
			this.selIndex--;
			this.No_of_Slides--;
			if(this.No_of_Slides==1)
			this.removeSlideBtn.enabled=false;
			updateThumbPanel();
			//updateMakePanel();
		}
		
		private function changeSelIndex(event:MouseEvent):void{
			trace("this is the Selected Index "+this.thumbArray.indexOf(event.currentTarget));
			trace("this is the Checked Selected Index "+event.currentTarget.label);
			trace("Chutiyapa " +this.selChildIndex.int);
			this.selIndex=this.thumbArray.indexOf(event.currentTarget);
			//updateMakePanel();
		}
		
		private function updateThumbPanel():void{
			var i :int=new int;
			i=0;
			thumbY=0;
			trace("yaha bhi lo bhosdi "+this.thumbArray);
			this.thumbSlideCnvs.removeAllChildren();
			for each(var tempCnvs :Canvas in this.thumbArray){
				tempCnvs.label=i.toString();
				tempCnvs.x=10;
				tempCnvs.y=thumbY+10;
				tempCnvs.width=this.thumbSlideCnvs.width-20;
				tempCnvs.height=80;
				thumbY=tempCnvs.height+tempCnvs.y;	
				this.thumbSlideCnvs.addChild(tempCnvs);
				i++;
			}
		}
		
		private function addImage(event:MouseEvent):void{

			var file :File=new File;
			var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
			file.browseForOpen("Add image (*.jpeg;*.png;*.jpg;*.bmp;)",[imagesFilter]);
			file.addEventListener(Event.SELECT,insertImage);
		}
		
		private function insertImage(event:Event):void{
			var imgCntnr : ImageCnvs=new ImageCnvs;
			var imgMakeCntnr : ImageCnvs=new ImageCnvs;
			
			var addOnslideReqObj : Object=new Object;
			addOnslideReqObj.message="Add on slide";
			addOnslideReqObj.source=event.target.url;
			addOnslideReqObj.addThis=imgCntnr;
			addOnslideReqObj.addOn=this.thumbArray[this.selIndex];
			addOnslideReqObj.slideNo=this.selIndex;
			addOnslideReqObj.Xpos=10;
			addOnslideReqObj.Ypos=10;
			addOnslideReqObj.PercentHt=40;
			addOnslideReqObj.PercentWd=40;
			model.fromViewtoModel(addOnslideReqObj);
			imgCntnr.setRefrence(this.thumbArray[this.selIndex],this.selChildIndex);
			
			/*var addOnMakeReqObj : Object=new Object;
			addOnMakeReqObj.message="Add on slide";
			addOnMakeReqObj.source=event.target.url;
			addOnMakeReqObj.addThis=imgMakeCntnr;
			addOnMakeReqObj.addOn=this.makeArray[this.selIndex];
			addOnMakeReqObj.Xpos=10;
			addOnMakeReqObj.Ypos=10;
			addOnMakeReqObj.PercentHt=40;
			addOnMakeReqObj.PercentWd=40;
			model.fromViewtoModel(addOnMakeReqObj);
			imgMakeCntnr.setRefrence(imgCntnr,this.thumbArray[this.selIndex],this.makeArray[this.selIndex],this.selChildIndex);*/
		}
		
		private function removeImage(event:MouseEvent):void{
			var removeFromSlideReqObj:Object=new Object;
			removeFromSlideReqObj.message="Remove from slide";
			removeFromSlideReqObj.RemoveFrom=this.thumbArray[this.selIndex];
			removeFromSlideReqObj.slideNo=this.selIndex;
			removeFromSlideReqObj.toremoveChildno=this.selChildIndex.int;
			model.fromViewtoModel(removeFromSlideReqObj);
			
			/*var removeFromThumbReqObj:Object=new Object;
			removeFromThumbReqObj.message="Remove from slide";
			removeFromThumbReqObj.RemoveFrom=this.thumbArray[this.selIndex];
			removeFromThumbReqObj.toremoveChildno=this.selChildIndex.int;
			model.fromViewtoModel(removeFromThumbReqObj);*/
		}
		
		/*private function updateMakePanel():void{
			
			this.makeSlideCnvs.removeAllChildren();
			this.makeSlideCnvs.addChild(this.makeArray[this.selIndex]);			
		}*/
		
		private function SaveSlide():void{
			trace("I am in save");
			var saveFile : File=new File;
			try{
			saveFile.browseForSave("Save As");
			saveFile.addEventListener(Event.SELECT,saveComplete);
			}
			catch(error:Error){
				Alert.show(error.message);
			}
		}
		
		private function saveComplete(event:Event):void{
			trace(event.currentTarget.url);
			var saveReqObj : Object=new Object;
			saveReqObj.message="Save slide" ;
			saveReqObj.targetFile=event.target;
			saveReqObj.toSaveArray=this.thumbArray;
			model.fromViewtoModel(saveReqObj);
		}
		
		private function openSlide():void{
			var file :File=new File;
			var imagesFilter:FileFilter = new FileFilter("Xml", "*.xml");
			file.browseForOpen("open slide",[imagesFilter]);
			file.addEventListener(Event.SELECT,openSlidecomplete);
		}
		
		private function openSlidecomplete(event:Event):void{
			trace(event.currentTarget.url);
			var openReqObj : Object=new Object;
			openReqObj.message="Open slide" ;
			openReqObj.targetURL=event.currentTarget.url;
			model.fromViewtoModel(openReqObj);
		}
		
		private function loadSlide(loadSlideobject:Object):void{
				/*image.source=content.@source.toString();
				image.x=content.@x;
				image.y=content.@y;
				image.height=content.@height;
				image.width=content.@width;
				imageArrayObject.img=image;
				imageArrayObject.slideNo=content.@slideNo;
				imageArrayObject.childIndex=content.@childIndex;
				imageArrayObject.NoOfSlides=XmlData.@NoOfSlides;
				openCompleteObject.openArray=this.openImageArray;*/
			
			var tempOpenArray : Array=new Array;
			var tempImgArray : Array=new Array;
			tempImgArray=loadSlideobject.openArray;
			
			this.thumbArray.splice(0);
			this.No_of_Slides=0;
			this.selIndex=0;
			for(var i:int=0 ;i<loadSlideobject.NoOfSlides;i++){
				var thumbCnvs : Canvas=new Canvas;
				thumbCnvs.setStyle("backgroundColor",0xFFFFFF);
				thumbCnvs.addEventListener(MouseEvent.CLICK,changeSelIndex);
				tempOpenArray.push(thumbCnvs);
				var addslideReqObj : Object=new Object;
				addslideReqObj.message="Add slide";
				this.model.fromViewtoModel(addslideReqObj);
				this.removeSlideBtn.enabled=true;
				this.No_of_Slides++;
				this.selIndex++;
			}
			
			//this.No_of_Slides=loadSlideobject.NoOfSlides;
			//this.selIndex=this.No_of_Slides-1;
			this.thumbArray=tempOpenArray;
			
			for each(var obj :Object in tempImgArray){
				/*var img :Image=new Image;
				var imgCnvs : ImageCnvs=new ImageCnvs;
				imgCnvs.x=obj.img.x;
				imgCnvs.y=obj.img.y
				imgCnvs.width=obj.img.width;
				imgCnvs.height=obj.img.height;
				imgCnvs.setRefrence(this.thumbArray[obj.slideNo],this.selChildIndex)*/
				/*img.source=obj.img.source
				img.x=obj.img.x;
				img.y=obj.img.y;
				img.width=obj.img.width;
				img.height=obj.img.height;
				//imgCnvs.addChild(img);
				this.thumbArray[obj.slideNo].addChild(img);*/
				//this.selChildIndex=0;
				//this.selChildIndex.int=1;
				var imgCntnr : ImageCnvs=new ImageCnvs;
				var imgMakeCntnr : ImageCnvs=new ImageCnvs;
				
				var addOnslideReqObj : Object=new Object;
				addOnslideReqObj.message="Add on slide";
				addOnslideReqObj.source=obj.img.source;
				addOnslideReqObj.addThis=imgCntnr;
				addOnslideReqObj.addOn=this.thumbArray[obj.slideNo];
				addOnslideReqObj.slideNo=obj.slideNo;
				addOnslideReqObj.Xpos=obj.img.x;
				addOnslideReqObj.Ypos=obj.img.y;
				addOnslideReqObj.PercentHt=40;
				addOnslideReqObj.PercentWd=40;
				model.fromViewtoModel(addOnslideReqObj);
				imgCntnr.setRefrence(this.thumbArray[obj.slideNo],this.selChildIndex);
			}
			updateThumbPanel();
		}
		
	//----------------------------------comminciation functions-------------------------------------//
	
	override public function update(model:Observable, infoObj_object:Object):void
		{
			var message:String=infoObj_object.message.toString();
			
			switch(message)
			{
				case "mouseUpEvent":
					trace("VideoView------->event:mouseup  infoObj.event :"+infoObj_object.event);
					super.recieveMouseUpEvent(infoObj_object.event);
					break;
			}
		}
	//----------------------------------------------------------------------------------------------//	
	}
}